import os,sys
import tarfile

def rmsvn(pdir):
    for dir in os.listdir(pdir):
        xdir = pdir + '\\' + dir
        if not os.path.isdir(xdir):
            continue
        if dir == '.svn' :
            command = 'rmdir /S /Q ' + xdir
            print command
            os.system(command)
        else:
            rmsvn(xdir)

def package():
    filename = 'python-game-editor.tar.gz'
    tar = tarfile.open(filename,'w:gz')
    print "begin packaging"
    for dir in os.listdir('.'):
        if dir != filename:
            tar.add(dir)
    tar.close()
    print "packaging finished"

def rmupload():
    command = 'rmdir /S /Q upload'
    os.system(command)

#rmsvn('.')
#rmupload()
package()
